package com.example.server.service.Impl;

import com.example.server.repository.GenericRepository;
import com.example.server.service.GenericService;

import java.io.Serializable;
import java.util.List;

public abstract class GenericServiceImpl<T extends Serializable, ID extends Number> implements GenericService<T, ID> {

    GenericRepository<T, ID> genericRepository;

    public abstract void setGenericRepository(GenericRepository<T, ID> genericRepository);

    @Override
    public List<T> queryAll() {

        return genericRepository.queryAll();
    }

    @Override
    public void create(T t) {

        genericRepository.create(t);
    }

    @Override
    public T queryById(ID id) {

        return genericRepository.queryById(id);
    }

    @Override
    public void modify(T t) {

        genericRepository.modify(t);
    }

    @Override
    public void removeById(ID id) {
        genericRepository.removeById(id);
    }

    @Override
    public T queryOne(String sqlId, Object parameter) {
        return genericRepository.queryOne(sqlId,parameter);
    }

    @Override
    public List<T> queryList(String sqlId, Object parameter) {
        return genericRepository.queryList(sqlId,parameter);
    }
}
